package com.dongdongshop.job;

import com.dongdongshop.service.SeckillGoodsService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.util.Date;
@DisallowConcurrentExecution//禁止并发
public class SeckillJob extends QuartzJobBean {
    @DubboReference
    private SeckillGoodsService seckillGoodsService;
    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        try {
            seckillGoodsService.catchPreHot();
            System.out.println("定时预热成功:" + new Date());
        }catch (Exception e){
            System.out.println("定时预热异常");
            e.printStackTrace();
        }
    }
}
